﻿using System.ComponentModel.DataAnnotations;
using BootstrapAdmin.DataAccess.Models;

namespace BootstrapAdmin.Web.ViewModels.Production
{
    public class DictInfoSearchModel : ITableSearchModel
    {
        [Display(Name = "标签")]
        public string? Category { get; set; }

        [Display(Name = "名称")]
        public string? Name { get; set; }

        [Display(Name = "别名")]
        public string? Alias { get; set; }

        [Display(Name = "代码")]
        public string? Code { get; set; }

        public IEnumerable<IFilterAction> GetSearchs()
        {
            var ret = new List<IFilterAction>();

            if (!string.IsNullOrEmpty(Name))
            {
                ret.Add(new SearchFilterAction(nameof(DictInfo.Name), Name));
            }

            if (!string.IsNullOrEmpty(Code))
            {
                ret.Add(new SearchFilterAction(nameof(DictInfo.Code), Code));
            }

            if (!string.IsNullOrEmpty(Category))
            {
                ret.Add(new SearchFilterAction(nameof(DictInfo.Category), Category));
            }

            if (!string.IsNullOrEmpty(Alias))
            {
                ret.Add(new SearchFilterAction(nameof(DictInfo.Alias), Alias));
            }

            return ret;
        }

        public void Reset()
        {
            Category = null;
            Name = null;
            Alias = null;
            Code = null;
        }
    }
}
